package Dao;
 
import java.sql.*;
import Dao.DBConn;
import Model.CurriculumBean;
public class CurriculumDAO {
    private Connection conn; 
    public CurriculumDAO() throws Exception {
        conn = DBConn.getConnection();
    }
    
    // 添加新课程
    public void insertCurriculum(CurriculumBean curriculum) throws Exception{
    	String sql = "insert into curriculum(CURRICULUM_ID,CURRICULUM_NAME,CURRICULUM_TEACHER_ID,CURRICULUM_TIME,CURRICULUM_MAXNUM,CURRICULUM_NOWNUM) values(?,?,?,?,?,?)";
        try{
            PreparedStatement prestmt = conn.prepareStatement(sql);
            prestmt.setInt(1, curriculum.getCurriculumID());
            prestmt.setString(2, curriculum.getCurriculumName());
            prestmt.setInt(3, curriculum.getCurriculumTeacherID());
            prestmt.setInt(4, curriculum.getCurriculumTime());
            prestmt.setInt(5, curriculum.getCurriculumMaxnum());
            prestmt.setInt(6, curriculum.getCurriculumNownum());
            
            prestmt.execute();
            prestmt.close();
            conn.close();
        }catch (Exception e){
            e.getMessage();
        }
    }
 
}